﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace c2iGMailNotifier.Converter
{
    public class DateTimeConverter : IValueConverter
    {
        #region IValueConverter Membres

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.GetType() != typeof(DateTime))
                throw new ArgumentException("value must be a DateTime", "value");

            if (targetType != typeof(string))
                throw new ArgumentException("targetType must be a string", "targetType");

            DateTime dateValue = (DateTime) value;

            if (dateValue.Date == DateTime.Now.Date)
                return dateValue.ToString("hhh:mmm");
            return dateValue.ToString("dd MMM");
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

}